package com.ebupt.migu.music.scheduled;

import com.ebupt.migu.music.service.SyncTsgService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


/**
 * @author tz
 */
@Slf4j
@Component
@EnableScheduling
public class SyncTsgTask {

    @Resource
    private SyncTsgService syncTsgService;

    /**
     * 同步tsg人群文件
     */
    @Scheduled(cron = "${tsg.sync}")
    public void syncUserGroup() {
        log.info("-----任务开始《同步tsg人群文件》-----");
        syncTsgService.syncUserGroup();
        log.info("-----任务结束《同步tsg人群文件》-----");
    }

    /**
     *  将tsg文件数据写入redis中
     */
    @Scheduled(initialDelay = 1000, fixedDelay = 1000 * 60)
    public void fileDataToRedis() {
        log.info("-----任务开始《人群uid入redis》-----");
        syncTsgService.fileDataToRedis();
        log.info("-----任务结束《人群uid入redis》-----");
    }
}
